Repository navigation
Conversation
The current directory is an attribute of the task group. The test checks that: - getcwd() gives the directory of chdir(); - setenv() and unsetenv() of PWD do not change it; - chdir() in a thread changes it for the task group; - after rename() of the directory, getcwd() gives the new name; - after rmdir() of the directory, getcwd() fails with ENOENT, also when a new directory of the same name appears. The test uses directories of the pseudo file system, so it needs no mounted file system. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
cederom
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
depends-on: apache/nuttx/pull/21907
Summary
Add a test of the current directory to ostest,
cwd_test()intesting/ostest/cwd.c. The current directory is an attribute of the task group. The test checks thatgetcwd()gives the directory ofchdir(), thatsetenv()andunsetenv()ofPWDdo not change it, thatchdir()in a thread changes it for the task group, thatgetcwd()gives the new name afterrename()of the directory, and thatgetcwd()fails withENOENTafterrmdir()of the directory, also when a new directory of the same name appears.The test checks apache/nuttx#21907 ("fs: Keep the current directory in the task group."). Merge this PR after it, and after #4061 (NSH sets
PWD).Impact
Only ostest. The test uses directories of the pseudo file system (
/ostest_cwd,/ostest_cwd2), so it needs no mounted file system. It is built whenCONFIG_DISABLE_PSEUDOFS_OPERATIONSis not set (Make and CMake). The thread case needs pthreads, thePWDcases the environment. At the end the test goes back to its directory andPWD, and removes its directories.Testing
QEMU with HVF, ostest with this test:
cwd_test: PASS, ostest exits with status 0cwd_test: PASS, ostest exits with status 0The thread case passes on master too: the threads of a task group already shared the directory through the environment. It stays as a guard.
tools/checkpatch.sh -c -u -m -gof nuttx passes on the commit.